﻿using System.Deployment.Application;

namespace dgmobile
{
  /// <summary>
  /// Static carrier of all around stuff.
  /// </summary>
  public static class Config
  {
    //Timer for app update check.

    //The ongoing var that enables or disables parts of the form and carries user info for data entry.
    public static User Operator;

    //Form to be opened for data entry.
    public static Form2 Popup;

    //Var to enable offline testing.
    public static bool TestMode;

    /// <summary>
    /// Defaults user to null and starts clock for update checks.
    /// </summary>
    static Config()
    {
      TestMode = false;
      Operator = null;
    }

    public static bool UpdateAvailable()
    {
      //Holds actual info.
      UpdateCheckInfo info = null;

      //Necessary steps.
      if(ApplicationDeployment.IsNetworkDeployed)
      {
        ApplicationDeployment deplo = ApplicationDeployment.CurrentDeployment;

        try
        {
          info = deplo.CheckForDetailedUpdate();
        }
        catch
        {
          return false;
        }

        //Self explanatory
        return info.UpdateAvailable;
      }

      return false;
    }
  }
}